<?php if(!defined('IN_FIRADIO')) {header('HTTP/1.1 403 Forbidden');exit('<h1>Access Denied</h1>');}?>
<?php $GLOBALS['script'][] = function() {?><script>
if (!vue.hasOwnProperty('computed')) vue.computed = {};
vue.methods.bill_opened = function (choice_hostuser) {
    // 累计开机
    if (window.isEmpty(choice_hostuser['opened'])) return 0;
    const opened = +(new Date(choice_hostuser['opened'].replace(/-/g,'/')));
    const day = (+new Date() - opened) / (86400 * 1000);
    return day;
};
vue.methods.bill_upday = function (choice_hostuser) {
    // 未出账单
    if (window.isEmpty(choice_hostuser['bill_uptime_begin'])) return 0;
    const bill_uptime_begin = +(new Date(choice_hostuser['bill_uptime_begin'].replace(/-/g,'/')));
    const day = (+new Date() - bill_uptime_begin) / (86400 * 1000);
    return day;
};
vue.methods.formatDays = function(days) {
    return (Math.round(days * 1000) / 1000) + '天';
}
vue.methods.bill_hold = function (choice_hostuser) {
    // 押金天数
    const dayminpoint = parseFloat(choice_hostuser['dayminpoint']);
    const holdbalance = parseFloat(choice_hostuser['holdbalance']);
    return (holdbalance / dayminpoint);
};
vue.methods.bill_unpaid = function (choice_hostuser) {
    // 剩余可用
    const dayminpoint = parseFloat(choice_hostuser['dayminpoint']);
    const bill_amount_unpaid = parseFloat(choice_hostuser['bill_amount_unpaid']);
    return (bill_amount_unpaid / dayminpoint);
};
vue.methods.value_remaindays = function (choice_hostuser) {
    return vue.methods.bill_hold(choice_hostuser) - vue.methods.bill_unpaid(choice_hostuser) - vue.methods.bill_upday(choice_hostuser);
}
vue.methods.point_to_yuan = function (cpuseconds) {
    return (Math.floor(cpuseconds / 100) / 100) + '元';
};
vue.methods.ntusercputime = function () {
    window.open('/panel.html#/panel/yun-ntusercputime.html');
};
</script><?php }?>
<div class="form-horizontal">
    <div class="form-group">
        <label class="col-sm-3 control-label">主机配置信息</label>
        <div class="col-sm-9">
            <div class="form-control">
                {{choice_hostuser['host_title']}} (机号:{{choice_hostuser['host_name']}})
            </div>
        </div>
    </div>
    <div class="form-group">
        <label class="col-sm-3 control-label">操作系统</label>
        <div class="col-sm-9">
            <div class="form-control">
                <span style="color:red">{{choice_hostuser['host_osname']}}</span>
            </div>
        </div>
    </div>
    <div class="form-group">
        <label class="col-sm-3 control-label">联网线路</label>
        <div class="col-sm-9">
            <div class="form-control">
                <span style="color:red">{{choice_hostuser['host_isp_title']}}</span>
                上行: <span style="color:red">{{choice_hostuser['bandwidth_upload_mbps']}}Mbps</span>
                下行: <span style="color:red">{{choice_hostuser['bandwidth_download_mbps']}}Mbps</span>
            </div>
        </div>
    </div>
    <div class="form-group">
        <label class="col-sm-3 control-label">套装规格</label>
        <div class="col-sm-9">
            <div class="form-control">
                <span style="color:red">{{choice_hostuser['pack_name']}}{{choice_hostuser['pack_title']}}</span>
                CPU:<span style="color:red">{{choice_hostuser['limit_cpucore']}}核</span>
                内存:<span style="color:red">{{choice_hostuser['limit_ramgb']}}G</span>
                硬盘:<span style="color:red">{{choice_hostuser['limit_storagegb']}}G</span>
            </div>
        </div>
    </div>
    <div class="form-group">
        <label class="col-sm-3 control-label">计费价格</label>
        <div class="col-sm-9">
            <div class="form-control" v-if="choice_hostuser['host_type']==1">
                已交押金:<span style="color:red">{{point_to_yuan(choice_hostuser['holdbalance'])}}</span>永久使用，CPU点数计费
                <button class="btn btn-info btn-xs" type="button" v-on:click="ntusercputime">计费记录</button>
            </div>
            <div class="form-control" v-if="choice_hostuser['host_type']==2">
                每日固定:<span style="color:red">{{point_to_yuan(choice_hostuser['dayminpoint'])}}</span>
                已交押金:<span style="color:red">{{point_to_yuan(choice_hostuser['holdbalance'])}}</span>
            </div>
        </div>
    </div>
    <div class="form-group" v-if="choice_hostuser['opened']">
        <label class="col-sm-3 control-label">开机时间</label>
        <div class="col-sm-9">
            <div class="form-control" v-if="choice_hostuser['host_type']==1">
                <span style="color:red">{{formatDays(bill_opened(choice_hostuser))}}</span>
                不限制时间，CPU点数单独计费
                <button class="btn btn-info btn-xs" type="button" v-on:click="ntusercputime">计费记录</button>
            </div>
            <div class="form-control" v-if="choice_hostuser['host_type']==2">
                <span style="color:red">{{formatDays(bill_opened(choice_hostuser))}}</span>
                （已出账 <span style="color:red">{{formatDays(bill_opened(choice_hostuser)-bill_upday(choice_hostuser))}}</span>
                +
                未出账 <span style="color:red">{{formatDays(bill_upday(choice_hostuser))}}</span>）
            </div>
        </div>
    </div>
    <div class="form-group" v-if="choice_hostuser['opened']&&choice_hostuser['host_type']==2">
        <label class="col-sm-3 control-label">剩余可用</label>
        <div class="col-sm-9">
            <div class="form-control">
                <span style="color:red">{{formatDays(value_remaindays(choice_hostuser))}}</span>
                （押金 <span style="color:red">{{formatDays(bill_hold(choice_hostuser))}}</span>
                -
                欠费 <span style="color:red">{{formatDays(bill_unpaid(choice_hostuser))}}</span>
                -
                未出账 <span style="color:red">{{formatDays(bill_upday(choice_hostuser))}}</span>）
            </div>
        </div>
    </div>
    <div class="form-group">
        <label class="col-sm-3 control-label">当前状态</label>
        <div class="col-sm-9">
            <div class="form-control">
                <span v-if="choice_hostuser['opened']" style="color: green;">已开通</span>
                <span v-else style="color: blue;">
                    <button class="btn btn-info btn-xs" type="button" v-on:click="tabclick('open')">请开通</button>
                </span>
                {{choice_hostuser.respond_message}}
            </div>
        </div>
    </div>
    <div class="form-group" v-if="0">
        <label class="col-sm-3 control-label">内网IP地址</label>
        <div class="col-sm-9">
            <span class="form-control" style="color:red">{{choice_hostuser['lanipv4']}}</span>
        </div>
    </div>
    <div class="form-group" v-if="choice_hostuser['opened']">
        <label class="col-sm-3 control-label">远程连接地址</label>
        <div class="col-sm-9">
            <div class="form-control">
                <span style="color:red" v-if="choice_hostuser['host_type']==2">
                    <span style="color:red" v-if="choice_hostuser['vps_wanipv4']">
                        {{choice_hostuser['vps_wanipv4']}}
                    </span>
                    <span style="color:red" v-else>请先开通</span>
                </span>
                <span style="color:red" v-else-if="choice_hostuser['rdpaddr']">
                    {{choice_hostuser['rdpaddr']}}:{{choice_hostuser['rdpport']}}
                    <button class="btn btn-info btn-xs" type="button" v-on:click="start_rdp()">快速远程</button>
                </span>
            </div>
        </div>
    </div>
    <div class="form-group" v-if="choice_hostuser['opened']">
        <label class="col-sm-3 control-label">远程用户名</label>
        <div class="col-sm-9">
            <div class="form-control">
                <span style="color:bule" v-if="choice_hostuser['host_type']==1">
                    <span style="color:red">{{choice_hostuser['username']}}</span>
                    （标准用户）
                </span>
                <span style="color:bule" v-if="choice_hostuser['host_type']==2">
                    <span style="color:red">{{choice_hostuser['vps_username']}}</span>
                    （管理账号）
                </span>
            </div>
        </div>
    </div>
</div>
<form class="form-horizontal" method="post" v-on:submit="submit_ticket" onsubmit="return false;">
    <div class="box-footer">
        <div class="box-footer col-sm-4 col-xs-12">
            <button v-if="choice_hostuser['opened']" type="button" class="btn btn-info btn-block btn-flat" v-on:click="tabclick('admin')">管理主机</button>
            <button v-else type="button" class="btn btn-info btn-block btn-flat" v-on:click="tabclick('open')">开通主机</button>
        </div>
        <div class="box-footer col-sm-4 col-xs-12">
            <button type="button" class="btn btn-danger btn-block btn-flat" v-on:click="refund" :disabled="disabled>0">退回押金</button>
        </div>
        <div class="box-footer col-sm-4 col-xs-12">
            <button type="button" class="btn btn-default btn-block btn-flat" v-on:click="flag.main='list';toTop()">返回列表</button>
        </div>
    </div>
</form>
